package com.starsea.book.ui.newpage.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.starsea.book.databinding.ItemHomeBookCityBinding
import com.starsea.book.ui.newpage.entity.BookTabTitleEntity
import com.starsea.book.ui.newpage.utils.loadNormalImage

/**
 * @author Lee
 * @createTime 2024-07-12 20 GMT+8
 * @desc :
 */
class BookDepositoryAdapter(var mContext: Context) :
    BaseQuickAdapter<BookTabTitleEntity, BookDepositoryAdapter.MyViewHolder>() {

    override fun onBindViewHolder(holder: MyViewHolder, position: Int, item: BookTabTitleEntity?) {
        holder.binding.tvTitle.text = item!!.typeTitle
        holder.binding.tvContent.text = "${item.countNum}册"
        holder.binding.ivCover.loadNormalImage(mContext, item.typePic ?: "")
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int,
    ): MyViewHolder {
        return MyViewHolder(parent = parent)
    }

    class MyViewHolder(
        parent: ViewGroup,
        val binding: ItemHomeBookCityBinding = ItemHomeBookCityBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

}